package com.example.weight.greenSeasons.flocculation;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.example.weight.R;
import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;

public class xuningRoleSelectActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chose_role);

        Intent previousIntent = getIntent();
        String name = previousIntent.getStringExtra("name");
        String type = previousIntent.getStringExtra("type");
        String factory = previousIntent.getStringExtra("factory");
        TitleBar titleBar = findViewById(R.id.role_select_titleBar);
        titleBar.setOnTitleBarListener(new OnTitleBarListener() {
            @Override
            public void onLeftClick(View v) { finish(); }
            @Override
            public void onTitleClick(View v) {}
            @Override
            public void onRightClick(View v) {}
        });

        RadioGroup radioGroup = findViewById(R.id.role_select_group);
        RadioButton radioButton = findViewById(R.id.radioButton);
        radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
            RadioButton button = findViewById(checkedId);
            String role = button.getText().toString();

            Intent intent;
            switch (type) {
                case "daily":
                    if(radioButton.isChecked()){
                        intent = new Intent(xuningRoleSelectActivity.this,
                                xuningribaoyangChecker.class);
                        break;
                    }
                    intent = new Intent(xuningRoleSelectActivity.this,
                            xuningribaoyang.class);
                    break;
                case "daily_old":
                    if(radioButton.isChecked()){
                        intent = new Intent(xuningRoleSelectActivity.this,
                                xuningribaoyangChecker_old.class);
                        break;
                    }
                    intent = new Intent(xuningRoleSelectActivity.this,
                            xuningribaoyang_old.class);
                    break;
//                case "daily_checker":
//                    intent = new Intent(xuningRoleSelectActivity.this,
//                            xuningribaoyangChecker.class);
//                    break;
                case "week":
                    if(radioButton.isChecked()){
                        intent = new Intent(xuningRoleSelectActivity.this,
                                xuningzhoubaoyangChecker.class);
                        break;
                    }
                    intent = new Intent(xuningRoleSelectActivity.this,
                            xuningzhoubaoyang.class);
                    break;
//                case "week_checker":
//                    intent = new Intent(xuningRoleSelectActivity.this,
//                            xuningzhoubaoyangChecker.class);
//                    break;
//                case "month_checker":
//                    intent = new Intent(xuningRoleSelectActivity.this,
//                            xuningyuebaoyangChecker.class);
//                    break;
                default:
//                    if(radioButton.isChecked()){
//                        intent = new Intent(xuningRoleSelectActivity.this,
//                                xuning.class);
//                        break;
//                    }
                    intent = new Intent(xuningRoleSelectActivity.this,
                            xuningyuebaoyang_nav.class);
                    break;
            }
            intent.putExtra("name", name);
            intent.putExtra("role", role);
            intent.putExtra("factory", factory);
            startActivity(intent);
        });
    }
}